using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SigmaStock_Components;
using System.Data.OleDb;

namespace project
{
    public partial class Retailer_Credit : Form
    {
        OleDbConnection conn;
        OleDbCommand command;
        string query;
        public static string rname = "";
        int amt_due = 0;

        public Retailer_Credit()
        {
            InitializeComponent();
            dbconnection();
            textBox1.Text = rname;

        }
        private void dbconnection()
        {
            conn = DBComponent.Mag_DealerDB.dbconnection();
            conn.Open();
            command = new OleDbCommand();
            command.Connection = conn;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (ValidationRet_Credit())
            {
                int credit_amt = int.Parse(textBox2.Text);

                query = "insert into retailer_credit values ('" + rname + "','" + credit_amt + "','" + amt_due + "');";
                command.CommandText = query;
                command.ExecuteNonQuery();
                MessageBox.Show("Data Inserted Successfully !!!");
                Application.OpenForms["Retailer_Credit"].Close();
            }
        }

        private bool ValidationRet_Credit()
        {
            if (String.IsNullOrEmpty(textBox2.Text) || !(Validation.IsPositiveNumber(textBox2.Text)))
            {
                //textBox3.Visible = true;
                textBox3.Visible = true;
                Console.Beep();
                textBox3.Text = "Check Initial Deposit";
                return false;
            }
            return true;
        }
    }
}